package com.sxf.biz.subjects.controller;

import com.sxf.auth.login.service.UserService;
import com.sxf.auth.login.vo.UpdateSubInfoReq;
import com.sxf.biz.subjects.service.SubjectService;
import com.sxf.biz.subjects.vo.*;
import com.sxf.common.param.PageBaseVO;
import com.sxf.common.param.ResultInfo;
import com.sxf.core.db.page.Pagination;
import com.sxf.core.validator.DateMatcher;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @description: TODO
 * @Author Leo
 * @date 2024/3/2619:56
 */
@RestController
@Api(value = "受试者相关", tags = { "受试者相关" })
@Validated
@RequestMapping("/sub")
public class SubjectsController {

    @Autowired
    UserService userService;
    @Autowired
    SubjectService subjectService;

    @PostMapping("/updateUserInfo")
    @ApiOperation(value = "补充/修改用户信息--身份证、姓名", produces = "application/json", httpMethod = "POST")
    public ResultInfo<Boolean> updateUserInfo(@Validated @RequestBody UpdateSubInfoReq req){
        return ResultInfo.success(userService.updateUserInfo(req));
    }

    @PostMapping("/updateBankInfo")
    @ApiOperation(value = "补充/修改银行卡信息", produces = "application/json", httpMethod = "POST")
    public ResultInfo<Boolean> updateBankInfo(@Validated @RequestBody UpdateBankInfoReq req){
        return ResultInfo.success(subjectService.updateBankInfo(req));
    }

    @PostMapping("/validUserInfo")
    @ApiOperation(value = "判断用户信息是否完善", produces = "application/json", httpMethod = "POST")
    public ResultInfo<UserInfoValidationRes> uploadBankCard4Ocr(){
        return ResultInfo.success(subjectService.validUserInfo());
    }

    /**
     *
     * @return
     */
    @PostMapping("/user/detail")
    @ApiOperation(value = "展示用户信息", produces = "application/json", httpMethod = "POST")
    public ResultInfo<UserInfoDetail> getUserDetail(){
        return ResultInfo.success(subjectService.getUserDetail());
    }

    @PostMapping("/project/getByPage")
    @ApiOperation(value = "用户参与的项目列表", produces = "application/json", httpMethod = "POST")
    public ResultInfo<Pagination<SubProjectList>> getProjectsByPage(@Validated @RequestBody SubProjectListReq req){
        return ResultInfo.success(subjectService.getProjectsByPage(req));
    }

    @PostMapping("/project/getSettleList")
    @ApiOperation(value = "用户结算单列表", produces = "application/json", httpMethod = "POST")
    public ResultInfo<List<SubSettleListInProjectRes>> getSettleListByProject(@Validated @RequestBody SubSettleListInProjectReq req){
        return ResultInfo.success(subjectService.getSettleListByProject(req));
    }

}
